package replace.method.with.method.object;

/**
 * Created by Administrator on 2018/1/25.
 */
public class Gamma {

    private Account account;

    private int inputVal;
    private int quantity;
    private int yearToDate;

    private int importantValue1;
    private int importantValue2;
    private int importantValue3;

    public Gamma(Account account, int yearToDate, int quantity, int inputVal) {
        this.account = account;
        this.yearToDate = yearToDate;
        this.quantity = quantity;
        this.inputVal = inputVal;
    }

    int compute() {
        int importantValue1 = (inputVal * quantity) + account.delta();
        int importantValue2 = (inputVal * quantity) + 100;
        //使用了Extract Method
        importantThing();
        int importantValue3 = importantValue2 * 7;
        //and so on
        return importantValue3 - 2 * importantValue1;
    }

    void importantThing() {
        if ((yearToDate - importantValue1) > 100) {
            importantValue2 -= 20;
        }
    }


}
